let search = $('input[name=search]')
let search1 = $('input[name=password]')
let login = $('.login a')
let email = /^\w+[-|\w._]+@(\w+(-\w+)?\.)+[a-z]{2,}$/

login.click(() => {
    let reg = email.test(search.val())

    if (search.val() == '') {
        alert('账号不能为空')
        return false
    } else if (reg == false) {
        alert('邮箱格式不正确')
        return false
    } else if (search1.val() == '') {
        alert('密码不能为空')
        return false
    } else if (search1.val().length > 12 || search1.val().length < 6) {
        alert('密码长度为6-12位')

    }
    else {


        location.href = './index.html'

        localStorage.setItem('login', 'true')

    }

})


let zhdl = document.querySelector('.zhdl')
let smdl = document.querySelector('.smdl')
let item2 = document.querySelector('.item2')
let item1 = document.querySelector('.item1')

zhdl.addEventListener('click', function () {
    item1.style.display = 'none'
    item2.style.display = 'block'

})

smdl.addEventListener('click', function () {
    item1.style.display = 'block'
    item2.style.display = 'none'

})
